<template>
  <div class="hotel-form">

    <el-form class="form" ref="form" :model="form" label-width="90px">
      <el-form-item label="城市" prop="city">
        <el-select v-model="form.city" placeholder="请选择城市">
          <el-option v-for="city in cities" :key="city.value" :label="city.label" :value="city.value"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="酒店名称" prop="name">
        <el-input v-model="form.name" placeholder="请输入酒店名称"></el-input>
      </el-form-item>
      <el-form-item label="酒店电话" prop="phone">
        <el-input v-model="form.phone" placeholder="请输入酒店电话"></el-input>
      </el-form-item>
      <el-form-item label="酒店地址" prop="address">
        <el-input v-model="form.address" placeholder="请输入酒店地址"></el-input>
      </el-form-item>
      <el-form-item label="酒店图片" prop="image">
        <el-upload
          class="upload-demo"
          :action="uploadUrl"
          :on-success="handleSuccess"
          :show-file-list="false"
        >
          <el-button size="small" type="primary">点击上传</el-button>
        </el-upload>
      </el-form-item>
      <el-form-item label="酒店大致价格" prop="price">
        <el-input v-model.number="form.price" placeholder="请输入酒店大致价格"></el-input>
      </el-form-item>
      <el-form-item label="酒店评分" prop="rating">
        <el-input v-model.number="form.rating" placeholder="请输入酒店评分"></el-input>
      </el-form-item>
      <el-form-item label="酒店评论" prop="comment">
        <el-input type="textarea" v-model="form.comment" placeholder="请输入酒店评论"></el-input>
      </el-form-item>
      <el-form-item label="酒店简介" prop="description">
        <el-input type="textarea" v-model="form.description" placeholder="请输入酒店简介"></el-input>
      </el-form-item>
      <el-form-item label="酒店经度" prop="longitude">
        <el-input v-model.number="form.longitude" placeholder="请输入酒店经度"></el-input>
      </el-form-item>
      <el-form-item label="酒店纬度" prop="latitude">
        <el-input v-model.number="form.latitude" placeholder="请输入酒店纬度"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm('form')">提交</el-button>
        <el-button @click="resetForm('form')">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>

export default {
  name: 'HotelSystemAdminCc',

  data () {
    return {
      form: {
        city: '',
        name: '',
        phone: '',
        address: '',
        price: 0,
        rating: 0,
        comment: '',
        description: '',
        latitude: '',
        longitude: ''
      }

    }
  },
  methods: {
    submitForm () {
      this.$refs.form.validate(valid => {
        if (valid) {
          // 提交表单
          console.log(this.form)
        } else {
          console.log('表单验证失败')
          return false
        }
      })
    },
    resetForm () {
      this.$refs.form.resetFields()
    },
    handleSuccess (response, file, fileList) {
      console.log('上传成功')
    }
  }
}
</script>

<style lang="less" scoped>
.hotel-form {
  margin: 50px auto;
  width: 600px;
  padding: 30px;
  border: 1px solid #ccc;
  border-radius: 5px;
}

.form-title {
  text-align: center;
}

.form {
  margin-top: 30px;
}

.el-form-item__label {
  font-weight: bold;
}

.el-form-item__content {
  margin-left: 120px;
  width: 400px;
}

.el-input__inner,
.el-select__input {
  border-radius: 5px;
}

.el-upload__tip {
  margin-left: 120px;
}

.el-button {
  margin-right: 20px;
}

.el-form-item:last-child {
  margin-bottom: 0;
}
</style>
